let list=document.querySelector(".list");
if(!list.querySelector(".color")){
  let spread = document.querySelector(".spread");
    spread.style.display = "block";
    let bid=document.querySelector(".news").getAttribute("bid")

  $.ajax({
    url: `/weibo/blog/getBlogComment?id=${bid}`,
    type: "get",
    success: function (result) {
      console.log(result.length);
      let comment = document.querySelector(".comment");
      comment.innerHTML = "";
      let blogSkip = document.querySelector(".blog-skip");
      console.log(blogSkip);




        for (let i = 0; i < 5; i++) {
          if (result[i].likes == 0) {
            result[i].likes = "";
          }
          comment.innerHTML =
              comment.innerHTML +
              ` <div class="item1" cid="${result[i].id}">
                    <div class="comment-list">
                      <a href="">
                       <div class="comment-head">
                          <img
                           
                            src="${result[i].userAvatarUrl}"
                            alt=""
                           />
                        </div>
                      </a>
                      <div class="comment-details">
                        <a href="" class="comment-name"> <span>${setText(
                  result[i].username
              )}</span> </a>:
                        <span class="c-content">${setText(
                  result[i].comment
              )}</span>
                      <div class="comment-bottom">
                         <div class="c-time">${
                  result[i].publishTime
              }   ${setText(result[i].address)}</div>
                         <div class="comment-fn">
                            <div class="c-complain" otherId=${
                  result[i].otherId
              } cid="${
                  result[i].id
              }" onclick="removeFirstComment(this)">
                            <i class="iconfont remove hidden">&#xe64c;</i>
                           
                            </div>
                            <div class="reply" cid=${result[i].id} logid=${
                  result[i].uid
              }>
                              <i class="iconfont">&#xe695;</i>
                            </div>
                            <div class="c-like" onclick="likeComment(this)"  cid=${
                  result[i].id
              }>
                              <i class="iconfont">&#xe600;</i><span>${
                  result[i].likes
              }</span>
                            </div>
                          </div> 
                        </div>
                      </div>
                    </div>
                 `;
        }
        let item1 = document.getElementsByClassName("item1");
        for (let i = 0; i < 5; i++) {
          // 二级评论的数据（数组）

          let list = result[i].list;

          if (result[i].likes == 0) {
            result[i].likes = " ";
          }

          if (list.length > 0) {
            for (let j = 0; j < 1; j++) {
              if (list[j].likes == 0) {
                list[j].likes = "";
              }
              item1[i].innerHTML =
                  item1[i].innerHTML +
                  `<div class="list2" cid=${list[j].id}>
                  <div class="list2-bar"></div>
                  <div class="list2-details">
                    <a href="" class="list2-name"><span>${setText(
                      list[j].username
                  )}:</span></a>
                    <span class="list2-content">${setText(
                      list[j].comment
                  )}</span>
                  </div>
                  <div class="list2-bottom">
                    <div class="list2-time">${list[j].publishTime}  ${
                      list[j].address
                  }</div>
                      <div class="list2-fn">
                      <div class="list2-complain" otherId=${list[j].otherId}>
                      <i class="iconfont remove hidden" onclick="removeSecondComment(this)">&#xe64c;</i>
                      </div>
                      
                      <div class="list2-like" onclick="likeComment(this)" cid=${
                      list[j].id
                  }>
                        <i class="iconfont">&#xe600;</i> <span>${
                      list[j].likes
                  }</span>
                      </div>
                    </div>
            </div>
                  </div>
                </div>`;
            }

            // 下面循环结尾多一个</div>是对item1进行结尾
            if (list.length > 1) {
              item1[i].innerHTML =
                  item1[i].innerHTML +
                  `<div class="list2-more ">
                  <div class="list2-bar"></div>
                       <a href="javascript:;" class="more-reply" id=${bid} index=${i}>共${list.length}条回复</a>
                       <i class="iconfont bottom">&#xe62e;</i>
                     </div>
                   </div>`;
            } else {
              comment.innerHTML = comment.innerHTML + `</div>`;
            }
          }
          judgeSecCom(comment);
          more();
          replyWindow();
          commentfn();
          judgecom(comment);
          commentlimit();
          islike(comment);
          issecLike();
        }

    },
    error: function () {},
  });
}